import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterapp/HomePageWidget.dart';

import 'AnalysePageWidget.dart';
import 'HealthPageWidget.dart';
import 'MyPageWidget.dart';
import 'TreePageWidget.dart';

class BottomNavigationWidget extends StatefulWidget {

  final String title;
  BottomNavigationWidget({Key key, this.title}) : super(key: key);

  @override
  BottomNavigationWidgetState createState() => BottomNavigationWidgetState();
}

class BottomNavigationWidgetState extends State<BottomNavigationWidget> {

  int currentPage=0;
  List pageList=[
    HomePageWidget(),TreePageWidget(),AnalysePageWidget(),HealthPageWidget(),MyPageWidget()
  ];


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: this.pageList[this.currentPage],
      bottomNavigationBar: BottomNavigationBar(
        onTap: (int i){
          setState(() {
            currentPage = i;
          });
        },
        currentIndex: currentPage,
        items: [
          BottomNavigationBarItem(
            activeIcon: Container(
              height: 23,
              width: 23,
              child: Image(
                image: AssetImage('assets/images/home22.png'),
                fit: BoxFit.fill,
              ),
            ),
            title: Text('首页',style: TextStyle(
              color: currentPage == 0 ?Color(0XFFF16051):Colors.black,
              fontSize: 11
              ),
            ),
            icon: Container(
              height: 21,
              width: 21,
              child: Image(
                image: AssetImage('assets/images/home12.png'),
                fit: BoxFit.fill,
              ),
            )
          ),
          BottomNavigationBarItem(
              activeIcon: Container(
                height: 20,
                width: 20,
                child: Image(
                  image: AssetImage('assets/images/tree2.png'),
                  fit: BoxFit.fill,
                ),
              ),
              title: Text('树园',style: TextStyle(
                  color: Color(0XFFF16051),
                  fontSize: 11
              ),),
              icon: Container(
                height: 23,
                width: 23,
                child: Image(
                  image: AssetImage('assets/images/tree1.png'),
                ),
              )
          ),
          BottomNavigationBarItem(
              activeIcon: Container(
                height: 20,
                width: 20,
                child: Image(
                  image: AssetImage('assets/images/analyse22.png'),
                  fit: BoxFit.fill,
                ),
              ),
              title: Text('数据分析',style: TextStyle(
                  color: Color(0XFFF16051),
                  fontSize: 11
              ),),
              icon: Container(
                height: 20,
                width: 20,
                child: Image(
                  image: AssetImage('assets/images/analyse12.png'),
                  fit: BoxFit.fill,
                ),
              )
          ),
          BottomNavigationBarItem(
              activeIcon: Container(
                height: 20,
                width: 20,
                child: Image(
                  image: AssetImage('assets/images/baobiao22.png'),
                  fit: BoxFit.fill,
                ),
              ),
              title: Text('健康周报',style: TextStyle(
                  color: Color(0XFFF16051),
                  fontSize: 11
              ),),
              icon: Container(
                height: 20,
                width: 20,
                child: Image(
                  image: AssetImage('assets/images/baobiao12.png'),
                  fit: BoxFit.fill,
                ),
              )
          ),
          BottomNavigationBarItem(
              activeIcon: Container(
                height: 20,
                width: 20,
                child: Image(
                  image: AssetImage('assets/images/my22.png'),
                  fit: BoxFit.fill,
                ),
              ),
              title: Text('我的',style: TextStyle(
                  color: Color(0XFFF16051),
                  fontSize: 11
              ),),
              icon: Container(
                height: 21,
                width: 21,
                child: Image(
                  image: AssetImage('assets/images/my12.png'),
                  fit: BoxFit.fill,
                ),
              )
          ),
        ],
      ),

    );
  }
}